namespace Asmex.FileViewer
{
    using Asmex.ObjViewer;
    using System;
    using System.IO;

    public class RelocationBlock : Region
    {
        private uint _BlockSize;
        private Relocation[] _entries;
        private uint _PageRVA;

        public RelocationBlock(BinaryReader reader)
        {
            base.Start = reader.BaseStream.Position;
            this._PageRVA = reader.ReadUInt32();
            this._BlockSize = reader.ReadUInt32();
            uint num = (this._BlockSize / 2) - 4;
            this._entries = new Relocation[num];
            for (int i = 0; i < num; i++)
            {
                this._entries[i] = new Relocation(reader.ReadUInt16());
            }
            base.Length = reader.BaseStream.Position - base.Start;
        }

        public uint BlockSize
        {
            get
            {
                return this._BlockSize;
            }
        }

        [ObjViewer(Hex=true)]
        public uint PageRVA
        {
            get
            {
                return this._PageRVA;
            }
        }

        [ObjViewer(false)]
        public Relocation[] Relocations
        {
            get
            {
                return this._entries;
            }
        }
    }
}
